package icu.xuyijie.springbootlearning1.chapter1_2.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TestConfig {

    @Bean
    // 如果括号中的类存在，则 @Bean 才生效
    //@ConditionalOnClass(String.class)
    // 如果括号中的类不存在，则 @Bean 才生效
    //@ConditionalOnMissingClass("java.lang.String")
    @Conditional(MyCondition.class)
    public Student student() {
        Student student = new Student();
        student.setName("xyj");
        student.setAge(22);
        return student;
    }

}
